package com.fr.report.script.function;

import com.fr.base.core.DateUtils;
import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;
import com.fr.util.Utils;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class MONTHDELTA extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 2)
      return Primitive.ERROR_NAME;
    Object localObject1 = paramArrayOfObject[0];
    Object localObject2 = paramArrayOfObject[1];
    int i = Utils.objectToNumber(localObject2, false).intValue();
    Date localDate = (localObject1 instanceof Date) ? (Date)localObject1 : DateUtils.object2Date(localObject1, false);
    GregorianCalendar localGregorianCalendar = new GregorianCalendar();
    localGregorianCalendar.setTime(localDate);
    localGregorianCalendar.add(2, i);
    return localGregorianCalendar.getTime();
  }

  public Function.Type getType()
  {
    return Function.DATETIME;
  }

  public String getCN()
  {
    return "MONTHDELTA(date,delta):返回指定日期date后delta个月的日期。\n示例：\nMONTHDELTA(\"2008-08-08\", 4)等于2008-12-08。";
  }

  public String getEN()
  {
    return "";
  }
}